﻿using System.Data;

namespace DAL
{
    public class Warehouse_DAL : clsConnect
    {
        private static readonly clsConnect cls = new clsConnect();
        #region[Get-Data]
        public DataTable GetWarehouse()
        {
            cls.CreateNewSqlCommand();
            return cls.GetData("sp_tb_Warehouse_Search");
        }
        public DataTable GetWarehouseDetail_Edit(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Warehouse_Id", id);
            return cls.GetData("sp_tb_Warehouse_Detail");
        }
        public DataTable GetWarehouseBranch(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Branch_Id", id);
            return cls.GetData("sp_tb_Warehouse_Branch");
        }
        public static DataTable GetWarehouseFillter(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Branch_Id", id);
            return cls.GetData("sp_tb_Warehouse_Fillter");
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertWarehouse(ET.Warehouse_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Warehouse_Alias", data.Warehouse_Alias);
            cls.AddParameter("@Warehouse_Name", data.Warehouse_Name);
            cls.AddParameter("@Branch_Id", data.Branch_Id);
            cls.AddParameter("@Warehouse_Note", data.Warehouse_Note);
            return cls.ExecuteNonQuery("sp_tb_Warehouse_Insert");
        }
        public bool UpdateWarehouse(ET.Warehouse_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Warehouse_Id", data.Warehouse_Id);
            cls.AddParameter("@Warehouse_Alias", data.Warehouse_Alias);
            cls.AddParameter("@Warehouse_Name", data.Warehouse_Name);
            cls.AddParameter("@Branch_Id", data.Branch_Id);
            cls.AddParameter("@Warehouse_Note", data.Warehouse_Note);
            return cls.ExecuteNonQuery("sp_tb_Warehouse_Update");
        }
        public bool DeleteWarehouse(int id)
        {

            cls.CreateNewSqlCommand();
            cls.AddParameter("@Warehouse_Id", id);
            return cls.ExecuteNonQuery("sp_tb_Warehouse_Delete");
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Warehouse_Search");
        }
        #endregion
    }
}